package game;

import engine.EngineBase;
import math.vec3f;
import util.Tex;

public class Engine extends EngineBase {
    
    public Engine() {
        super( // Using 5 : 3 aspect ratio
//                1280, 768, // Window: width, height
//                640, 384 // Resolution: width, height
//                1280, 768
            1280, 720, 
            640, 360
        );
    }
    
    protected void loadImageFiles() {
        Tex.loader().load("checker");
        Tex.loader().load("icon");
        Tex.loader().load("jcge");
        Tex.loader().load("sky");
        Tex.loader().load("test");
    }
    
    private Player player;
    private World world;
    
    protected void onStart() {
        vec3f startPos = new vec3f(0, 0, -5);
        vec3f startAngles = new vec3f(0, 0, 0);
        player = new Player(startPos, startAngles);
        world = new World();
        mouse.lockMouseTo(viewportW / 2, viewportH / 2);
    }
    
    protected void update() {
        player.update(keys, mouse, timeCycle);
        world.render(renderEngine);
        
        renderEngine.rotate(player.rots);
        renderEngine.translate(-player.pos.x, -player.pos.y, -player.pos.z);
    }
    
    protected void perSecond() {
        System.out.println(framerate);
    }
    
    protected void onClose() {
        mouse.unlockMouse();
    }
    
}
